package com.zzzmode.httpjob.web.controller;

import com.jfinal.core.Controller;
import com.zzzmode.httpjob.web.model.ApiError;
import com.zzzmode.jobwork.utils.JsonUtil;

/**
 * Created by zl on 2014/12/7.
 */
public class BaseController extends Controller {


    public void renderJson(Object obj){
        if(obj == null){
            renderJson(JsonUtil.getGson().toJson(new ApiError(100)));
        }else {
            renderJson(JsonUtil.getGson().toJson(obj));
        }

    }


    protected ApiError buildApiError(int code, String msg){
        return new ApiError(code,msg);
    }

    protected ApiError paramsError(){
        return new ApiError(1);
    }

}
